<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<html>
	 <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
        <meta name="format-detection" content="telephone=no">
        <meta charset="UTF-8">

        <meta name="description" content="Violate Responsive Admin Template">
        <meta name="keywords" content="Super Admin, Admin, Template, Bootstrap">
    </head>
    <body>
	            <div class="row">
		            <div class="col-md-6">
		            	<h4 class="page-title">店铺信息</h4>
		            	<div class="row">
							<div class="col-md-12 form-group">
								<label>店铺名称</label>&emsp;：<span id="merchantName"></span>
							</div>
							<div class="col-md-12 form-group">
								<label>店铺类型</label>&emsp;：<span id="merchartClassifyId"></span>
							</div>
						</div>
						<div class="row">
							<div class="col-md-12 form-group">
								<label>店铺地址</label>&emsp;：<span id="merchantAddress"></span> 
							</div>
						</div>
						<div class="row">
							<div class="col-md-12 form-group">
								<label>店铺简介</label>&emsp;：<span id="merchartIntro"></span> 
							</div>
						</div>
		            </div>
		            <div class="col-md-6">
		            	<h4 class="page-title">个人信息</h4>
		            	<div class="row">
							<div class="col-md-12 form-group">
								<label>真实姓名</label>&emsp;：<span id="userName"></span>
							</div>
							<div class="col-md-12 form-group">
								<label>身份证号</label>&emsp;：<span id="idNo"></span>
							</div>
						</div>
						<div class="row">
							<div class="col-md-6 form-group">
								<label>手持身份证照片</label>
								<div class="row" id="certificatePhotoDiv">
								</div>
							</div>
							<div class="col-md-6 form-group">
								<label>手持营业执照</label>
								<div class="row" id="businessPhotoDiv">
								</div>
							</div>
						</div>
		            </div>
	            </div>
	            <div class="text-center" id="subDiv">
		        </div>
   </body>
   <script type="text/javascript">
   $(function(){
		$.ajax({
			 type:"POST",
	         url: "<%=path %>/manager/getShopClassifyList",
	         success: function(data,status,xhr){
	        	 var shopClassifyList=data;
	        	 $.ajax({
	    			 type:"POST",
	    	         url: "<%=path %>/manager/getShopInfoByMerchantId?merchantId=${param.merchantId}",
	    	         success: function(data,status,xhr){
	    	        	 $("#merchantName").html(data.merchant.merchantName);
	    	        	 for(var i=0;i<shopClassifyList.length;i++){
	    	        		 if(shopClassifyList[i].classifyId==data.merchant.merchartClassifyId){
	    	        		 	$("#merchantName").html(shopClassifyList[i].classifyName);
	    	        		 }
	    	        	 }
	    	        	 $("#merchartClassifyId").html(data.merchant.merchartClassifyId);
	    	        	 $("#merchantAddress").html(data.merchant.merchantAddress);
	    	        	 $("#merchartIntro").html(data.merchant.merchartIntro);
	    	        	 $("#userName").html(data.realName);
	    	        	 $("#idNo").html(data.idNo);
	    	        	 $('#certificatePhotoDiv').append('<div class="col-xs-12 col-md-12" id="addCertificatePhotoDiv"><img class="img-responsive" src="<%=path %>/manager/getApplyPhoto?photoUrl='+data.merchant.handIdcardImg+'" style="position:relative">'
									+'</div>');
						 $('#businessPhotoDiv').append('<div class="col-xs-12 col-md-12" id="addBusinessPhotoDiv"><img class="img-responsive" src="<%=path %>/manager/getApplyPhoto?photoUrl='+data.merchant.hardBusinessLicenseImg+'" style="position:relative">'
									+'</div>');
						 if(data.merchant.state==2){
							 $('#subDiv').html('<button class="btn btn-lg btn-primary"  style="width: 120px;" onclick="closeMerchant(${param.merchantId})" type="button">关闭店铺</button>')
						 }else{
							 $('#subDiv').html('<button class="btn btn-lg btn-primary"  style="width: 120px;" onclick="openMerchant(${param.merchantId})" type="button">打开店铺</button>')
						 }

	    	         }
	    		})
	         }
		})
   });
   function closeMerchant(id){
	   swal({ 
			  title: "是否确定关闭此店铺？", 
			  type: "warning",
			  showCancelButton: true, 
			  confirmButtonColor: "#DD6B55",
			  confirmButtonText: "关闭店铺！", 
			  cancelButtonText: "取消关闭！",
			  closeOnConfirm: false, 
			  closeOnCancel: true
			},
			function(isConfirm){ 
			    if(isConfirm){
			    	$.ajax({
						 type:"POST",
				         url: "<%=path %>/manager/stopShop?merchantId=${param.merchantId}",
				         success: function(data,status,xhr){
				        	 if(data==1){
				        		 swal({ 
						   			  title: "提交成功", 
						   			  text: "关闭成功", 
						   			  type: "success",
						   			},function(){
						        		 $("#tabId").bootstrapTable('refresh');
						        		 $('#myModal').modal('hide')
						   			});
				        		 
				        	 }else{
				        		 swal({ 
						   			  title: "提交失败", 
						   			  text: "关闭失败", 
						   			  type: "error",
						   			}); 
				        	 }
				         }
					})
			    }
			});
   }
   function openMerchant(id){
	   swal({ 
			  title: "是否确定打开此店铺？", 
			  type: "warning",
			  showCancelButton: true, 
			  confirmButtonColor: "#DD6B55",
			  confirmButtonText: "打开店铺！", 
			  cancelButtonText: "取消打开！",
			  closeOnConfirm: false, 
			  closeOnCancel: true
			},
			function(isConfirm){ 
			    if(isConfirm){
			    	$.ajax({
						 type:"POST",
				         url: "<%=path %>/manager/passShop?merchantId=${param.merchantId}",
				         success: function(data,status,xhr){
				        	 if(data==1){
				        		 swal({ 
						   			  title: "提交成功", 
						   			  text: "打开成功", 
						   			  type: "success",
						   			},function(){
						        		 $("#tabId").bootstrapTable('refresh');
						        		 $('#myModal').modal('hide')
						   			});
				        		 
				        	 }else{
				        		 swal({ 
						   			  title: "提交失败", 
						   			  text: "打开失败", 
						   			  type: "error",
						   			}); 
				        	 }
				         }
					})
			    }
			});
   }
   </script>
</html>